AMD IOMMU: Allow enabling iommu debug output at run time.
authorKeir Fraser <keir.fraser@citrix.com>
Fri, 18 Sep 2009 07:28:20 +0000 (08:28 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Fri, 18 Sep 2009 07:28:20 +0000 (08:28 +0100)
The old compile-time option is removed.

Signed-off-by: Wei Wang <wei.wang2@amd.com>
xen/drivers/passthrough/amd/iommu_acpi.c
xen/drivers/passthrough/amd/iommu_detect.c
xen/drivers/passthrough/amd/iommu_init.c
xen/drivers/passthrough/amd/iommu_intr.c
xen/drivers/passthrough/amd/iommu_map.c
xen/drivers/passthrough/amd/pci_amd_iommu.c
xen/drivers/passthrough/iommu.c
xen/include/asm-x86/hvm/svm/amd-iommu-proto.h

index 4d0f1f2ddfa662f996c5505ae27bf21782433c62..b3bbc332f364d806c475051e1a4ec263c34c844c 100644 (file)
@@ -181,7 +181,7 @@ static int __init register_exclusion_range_for_device(
     iommu = find_iommu_for_device(bdf);
     if ( !iommu )
     {
-        amd_iov_error("IVMD Error: No IOMMU for Dev_Id 0x%x!\n", bdf);
+        AMD_IOMMU_DEBUG("IVMD Error: No IOMMU for Dev_Id 0x%x!\n", bdf);
         return -ENODEV;
     }
     req = ivrs_mappings[bdf].dte_requestor_id;
@@ -261,7 +261,7 @@ static int __init parse_ivmd_device_select(
     bdf = ivmd_block->header.dev_id;
     if ( bdf >= ivrs_bdf_entries )
     {
-        amd_iov_error("IVMD Error: Invalid Dev_Id 0x%x\n", bdf);
+        AMD_IOMMU_DEBUG("IVMD Error: Invalid Dev_Id 0x%x\n", bdf);
         return -ENODEV;
     }
 
@@ -278,7 +278,7 @@ static int __init parse_ivmd_device_range(
     first_bdf = ivmd_block->header.dev_id;
     if ( first_bdf >= ivrs_bdf_entries )
     {
-        amd_iov_error(
+        AMD_IOMMU_DEBUG(
             "IVMD Error: Invalid Range_First Dev_Id 0x%x\n", first_bdf);
         return -ENODEV;
     }
@@ -286,7 +286,7 @@ static int __init parse_ivmd_device_range(
     last_bdf = ivmd_block->last_dev_id;
     if ( (last_bdf >= ivrs_bdf_entries) || (last_bdf <= first_bdf) )
     {
-        amd_iov_error(
+        AMD_IOMMU_DEBUG(
             "IVMD Error: Invalid Range_Last Dev_Id 0x%x\n", last_bdf);
         return -ENODEV;
     }
@@ -309,7 +309,7 @@ static int __init parse_ivmd_device_iommu(
                                     ivmd_block->cap_offset);
     if ( !iommu )
     {
-        amd_iov_error("IVMD Error: No IOMMU for Dev_Id 0x%x  Cap 0x%x\n",
+        AMD_IOMMU_DEBUG("IVMD Error: No IOMMU for Dev_Id 0x%x  Cap 0x%x\n",
                 ivmd_block->header.dev_id, ivmd_block->cap_offset);
         return -ENODEV;
     }
@@ -326,7 +326,7 @@ static int __init parse_ivmd_block(struct acpi_ivmd_block_header *ivmd_block)
     if ( ivmd_block->header.length <
          sizeof(struct acpi_ivmd_block_header) )
     {
-        amd_iov_error("IVMD Error: Invalid Block Length!\n");
+        AMD_IOMMU_DEBUG("IVMD Error: Invalid Block Length!\n");
         return -ENODEV;
     }
 
@@ -335,9 +335,9 @@ static int __init parse_ivmd_block(struct acpi_ivmd_block_header *ivmd_block)
     base = start_addr & PAGE_MASK;
     limit = (start_addr + mem_length - 1) & PAGE_MASK;
 
-    amd_iov_info("IVMD Block: Type 0x%x\n",ivmd_block->header.type);
-    amd_iov_info(" Start_Addr_Phys 0x%lx\n", start_addr);
-    amd_iov_info(" Mem_Length 0x%lx\n", mem_length);
+    AMD_IOMMU_DEBUG("IVMD Block: Type 0x%x\n",ivmd_block->header.type);
+    AMD_IOMMU_DEBUG(" Start_Addr_Phys 0x%lx\n", start_addr);
+    AMD_IOMMU_DEBUG(" Mem_Length 0x%lx\n", mem_length);
 
     if ( get_field_from_byte(ivmd_block->header.flags,
                              AMD_IOMMU_ACPI_EXCLUSION_RANGE_MASK,
@@ -356,7 +356,7 @@ static int __init parse_ivmd_block(struct acpi_ivmd_block_header *ivmd_block)
     }
     else
     {
-        amd_iov_error("IVMD Error: Invalid Flag Field!\n");
+        AMD_IOMMU_DEBUG("IVMD Error: Invalid Flag Field!\n");
         return -ENODEV;
     }
 
@@ -379,7 +379,7 @@ static int __init parse_ivmd_block(struct acpi_ivmd_block_header *ivmd_block)
                                        base, limit, iw, ir);
 
     default:
-        amd_iov_error("IVMD Error: Invalid Block Type!\n");
+        AMD_IOMMU_DEBUG("IVMD Error: Invalid Block Type!\n");
         return -ENODEV;
     }
 }
@@ -389,7 +389,7 @@ static u16 __init parse_ivhd_device_padding(
 {
     if ( header_length < (block_length + pad_length) )
     {
-        amd_iov_error("IVHD Error: Invalid Device_Entry Length!\n");
+        AMD_IOMMU_DEBUG("IVHD Error: Invalid Device_Entry Length!\n");
         return 0;
     }
 
@@ -404,7 +404,7 @@ static u16 __init parse_ivhd_device_select(
     bdf = ivhd_device->header.dev_id;
     if ( bdf >= ivrs_bdf_entries )
     {
-        amd_iov_error("IVHD Error: Invalid Device_Entry Dev_Id 0x%x\n", bdf);
+        AMD_IOMMU_DEBUG("IVHD Error: Invalid Device_Entry Dev_Id 0x%x\n", bdf);
         return 0;
     }
 
@@ -422,14 +422,14 @@ static u16 __init parse_ivhd_device_range(
     dev_length = sizeof(struct acpi_ivhd_device_range);
     if ( header_length < (block_length + dev_length) )
     {
-        amd_iov_error("IVHD Error: Invalid Device_Entry Length!\n");
+        AMD_IOMMU_DEBUG("IVHD Error: Invalid Device_Entry Length!\n");
         return 0;
     }
 
     if ( ivhd_device->range.trailer.type !=
          AMD_IOMMU_ACPI_IVHD_DEV_RANGE_END )
     {
-        amd_iov_error("IVHD Error: "
+        AMD_IOMMU_DEBUG("IVHD Error: "
                 "Invalid Range: End_Type 0x%x\n",
                 ivhd_device->range.trailer.type);
         return 0;
@@ -438,7 +438,7 @@ static u16 __init parse_ivhd_device_range(
     first_bdf = ivhd_device->header.dev_id;
     if ( first_bdf >= ivrs_bdf_entries )
     {
-        amd_iov_error(
+        AMD_IOMMU_DEBUG(
             "IVHD Error: Invalid Range: First Dev_Id 0x%x\n", first_bdf);
         return 0;
     }
@@ -446,12 +446,12 @@ static u16 __init parse_ivhd_device_range(
     last_bdf = ivhd_device->range.trailer.dev_id;
     if ( (last_bdf >= ivrs_bdf_entries) || (last_bdf <= first_bdf) )
     {
-        amd_iov_error(
+        AMD_IOMMU_DEBUG(
             "IVHD Error: Invalid Range: Last Dev_Id 0x%x\n", last_bdf);
         return 0;
     }
 
-    amd_iov_info(" Dev_Id Range: 0x%x -> 0x%x\n", first_bdf, last_bdf);
+    AMD_IOMMU_DEBUG(" Dev_Id Range: 0x%x -> 0x%x\n", first_bdf, last_bdf);
 
     for ( bdf = first_bdf; bdf <= last_bdf; bdf++ )
         add_ivrs_mapping_entry(bdf, bdf, ivhd_device->header.flags, iommu);
@@ -468,25 +468,25 @@ static u16 __init parse_ivhd_device_alias(
     dev_length = sizeof(struct acpi_ivhd_device_alias);
     if ( header_length < (block_length + dev_length) )
     {
-        amd_iov_error("IVHD Error: Invalid Device_Entry Length!\n");
+        AMD_IOMMU_DEBUG("IVHD Error: Invalid Device_Entry Length!\n");
         return 0;
     }
 
     bdf = ivhd_device->header.dev_id;
     if ( bdf >= ivrs_bdf_entries )
     {
-        amd_iov_error("IVHD Error: Invalid Device_Entry Dev_Id 0x%x\n", bdf);
+        AMD_IOMMU_DEBUG("IVHD Error: Invalid Device_Entry Dev_Id 0x%x\n", bdf);
         return 0;
     }
 
     alias_id = ivhd_device->alias.dev_id;
     if ( alias_id >= ivrs_bdf_entries )
     {
-        amd_iov_error("IVHD Error: Invalid Alias Dev_Id 0x%x\n", alias_id);
+        AMD_IOMMU_DEBUG("IVHD Error: Invalid Alias Dev_Id 0x%x\n", alias_id);
         return 0;
     }
 
-    amd_iov_info(" Dev_Id Alias: 0x%x\n", alias_id);
+    AMD_IOMMU_DEBUG(" Dev_Id Alias: 0x%x\n", alias_id);
 
     add_ivrs_mapping_entry(bdf, alias_id, ivhd_device->header.flags, iommu);
 
@@ -503,14 +503,14 @@ static u16 __init parse_ivhd_device_alias_range(
     dev_length = sizeof(struct acpi_ivhd_device_alias_range);
     if ( header_length < (block_length + dev_length) )
     {
-        amd_iov_error("IVHD Error: Invalid Device_Entry Length!\n");
+        AMD_IOMMU_DEBUG("IVHD Error: Invalid Device_Entry Length!\n");
         return 0;
     }
 
     if ( ivhd_device->alias_range.trailer.type !=
          AMD_IOMMU_ACPI_IVHD_DEV_RANGE_END )
     {
-        amd_iov_error("IVHD Error: "
+        AMD_IOMMU_DEBUG("IVHD Error: "
                 "Invalid Range: End_Type 0x%x\n",
                 ivhd_device->alias_range.trailer.type);
         return 0;
@@ -519,7 +519,7 @@ static u16 __init parse_ivhd_device_alias_range(
     first_bdf = ivhd_device->header.dev_id;
     if ( first_bdf >= ivrs_bdf_entries )
     {
-        amd_iov_error(
+        AMD_IOMMU_DEBUG(
             "IVHD Error: Invalid Range: First Dev_Id 0x%x\n", first_bdf);
         return 0;
     }
@@ -527,7 +527,7 @@ static u16 __init parse_ivhd_device_alias_range(
     last_bdf = ivhd_device->alias_range.trailer.dev_id;
     if ( last_bdf >= ivrs_bdf_entries || last_bdf <= first_bdf )
     {
-        amd_iov_error(
+        AMD_IOMMU_DEBUG(
             "IVHD Error: Invalid Range: Last Dev_Id 0x%x\n", last_bdf);
         return 0;
     }
@@ -535,12 +535,12 @@ static u16 __init parse_ivhd_device_alias_range(
     alias_id = ivhd_device->alias_range.alias.dev_id;
     if ( alias_id >= ivrs_bdf_entries )
     {
-        amd_iov_error("IVHD Error: Invalid Alias Dev_Id 0x%x\n", alias_id);
+        AMD_IOMMU_DEBUG("IVHD Error: Invalid Alias Dev_Id 0x%x\n", alias_id);
         return 0;
     }
 
-    amd_iov_info(" Dev_Id Range: 0x%x -> 0x%x\n", first_bdf, last_bdf);
-    amd_iov_info(" Dev_Id Alias: 0x%x\n", alias_id);
+    AMD_IOMMU_DEBUG(" Dev_Id Range: 0x%x -> 0x%x\n", first_bdf, last_bdf);
+    AMD_IOMMU_DEBUG(" Dev_Id Alias: 0x%x\n", alias_id);
 
     for ( bdf = first_bdf; bdf <= last_bdf; bdf++ )
         add_ivrs_mapping_entry(bdf, alias_id, ivhd_device->header.flags, iommu);
@@ -557,14 +557,14 @@ static u16 __init parse_ivhd_device_extended(
     dev_length = sizeof(struct acpi_ivhd_device_extended);
     if ( header_length < (block_length + dev_length) )
     {
-        amd_iov_error("IVHD Error: Invalid Device_Entry Length!\n");
+        AMD_IOMMU_DEBUG("IVHD Error: Invalid Device_Entry Length!\n");
         return 0;
     }
 
     bdf = ivhd_device->header.dev_id;
     if ( bdf >= ivrs_bdf_entries )
     {
-        amd_iov_error("IVHD Error: Invalid Device_Entry Dev_Id 0x%x\n", bdf);
+        AMD_IOMMU_DEBUG("IVHD Error: Invalid Device_Entry Dev_Id 0x%x\n", bdf);
         return 0;
     }
 
@@ -582,14 +582,14 @@ static u16 __init parse_ivhd_device_extended_range(
     dev_length = sizeof(struct acpi_ivhd_device_extended_range);
     if ( header_length < (block_length + dev_length) )
     {
-        amd_iov_error("IVHD Error: Invalid Device_Entry Length!\n");
+        AMD_IOMMU_DEBUG("IVHD Error: Invalid Device_Entry Length!\n");
         return 0;
     }
 
     if ( ivhd_device->extended_range.trailer.type !=
          AMD_IOMMU_ACPI_IVHD_DEV_RANGE_END )
     {
-        amd_iov_error("IVHD Error: "
+        AMD_IOMMU_DEBUG("IVHD Error: "
                 "Invalid Range: End_Type 0x%x\n",
                 ivhd_device->extended_range.trailer.type);
         return 0;
@@ -598,7 +598,7 @@ static u16 __init parse_ivhd_device_extended_range(
     first_bdf = ivhd_device->header.dev_id;
     if ( first_bdf >= ivrs_bdf_entries )
     {
-        amd_iov_error(
+        AMD_IOMMU_DEBUG(
             "IVHD Error: Invalid Range: First Dev_Id 0x%x\n", first_bdf);
         return 0;
     }
@@ -606,12 +606,12 @@ static u16 __init parse_ivhd_device_extended_range(
     last_bdf = ivhd_device->extended_range.trailer.dev_id;
     if ( (last_bdf >= ivrs_bdf_entries) || (last_bdf <= first_bdf) )
     {
-        amd_iov_error(
+        AMD_IOMMU_DEBUG(
             "IVHD Error: Invalid Range: Last Dev_Id 0x%x\n", last_bdf);
         return 0;
     }
 
-    amd_iov_info(" Dev_Id Range: 0x%x -> 0x%x\n",
+    AMD_IOMMU_DEBUG(" Dev_Id Range: 0x%x -> 0x%x\n",
             first_bdf, last_bdf);
 
     for ( bdf = first_bdf; bdf <= last_bdf; bdf++ )
@@ -629,14 +629,14 @@ static u16 __init parse_ivhd_device_special(
     dev_length = sizeof(struct acpi_ivhd_device_special);
     if ( header_length < (block_length + dev_length) )
     {
-        amd_iov_error("IVHD Error: Invalid Device_Entry Length!\n");
+        AMD_IOMMU_DEBUG("IVHD Error: Invalid Device_Entry Length!\n");
         return 0;
     }
 
     bdf = ivhd_device->special.dev_id;
     if ( bdf >= ivrs_bdf_entries )
     {
-        amd_iov_error("IVHD Error: Invalid Device_Entry Dev_Id 0x%x\n", bdf);
+        AMD_IOMMU_DEBUG("IVHD Error: Invalid Device_Entry Dev_Id 0x%x\n", bdf);
         return 0;
     }
 
@@ -655,7 +655,7 @@ static int __init parse_ivhd_block(struct acpi_ivhd_block_header *ivhd_block)
     if ( ivhd_block->header.length <
          sizeof(struct acpi_ivhd_block_header) )
     {
-        amd_iov_error("IVHD Error: Invalid Block Length!\n");
+        AMD_IOMMU_DEBUG("IVHD Error: Invalid Block Length!\n");
         return -ENODEV;
     }
 
@@ -663,7 +663,7 @@ static int __init parse_ivhd_block(struct acpi_ivhd_block_header *ivhd_block)
                                     ivhd_block->cap_offset);
     if ( !iommu )
     {
-        amd_iov_error("IVHD Error: No IOMMU for Dev_Id 0x%x  Cap 0x%x\n",
+        AMD_IOMMU_DEBUG("IVHD Error: No IOMMU for Dev_Id 0x%x  Cap 0x%x\n",
                 ivhd_block->header.dev_id, ivhd_block->cap_offset);
         return -ENODEV;
     }
@@ -676,10 +676,10 @@ static int __init parse_ivhd_block(struct acpi_ivhd_block_header *ivhd_block)
         ivhd_device = (union acpi_ivhd_device *)
             ((u8 *)ivhd_block + block_length);
 
-        amd_iov_info( "IVHD Device Entry:\n");
-        amd_iov_info( " Type 0x%x\n", ivhd_device->header.type);
-        amd_iov_info( " Dev_Id 0x%x\n", ivhd_device->header.dev_id);
-        amd_iov_info( " Flags 0x%x\n", ivhd_device->header.flags);
+        AMD_IOMMU_DEBUG( "IVHD Device Entry:\n");
+        AMD_IOMMU_DEBUG( " Type 0x%x\n", ivhd_device->header.type);
+        AMD_IOMMU_DEBUG( " Dev_Id 0x%x\n", ivhd_device->header.dev_id);
+        AMD_IOMMU_DEBUG( " Flags 0x%x\n", ivhd_device->header.flags);
 
         switch ( ivhd_device->header.type )
         {
@@ -727,7 +727,7 @@ static int __init parse_ivhd_block(struct acpi_ivhd_block_header *ivhd_block)
                 ivhd_block->header.length, block_length, iommu);
             break;
         default:
-            amd_iov_error("IVHD Error: Invalid Device Type!\n");
+            AMD_IOMMU_DEBUG("IVHD Error: Invalid Device Type!\n");
             dev_length = 0;
             break;
         }
@@ -759,7 +759,7 @@ static int __init parse_ivrs_block(struct acpi_ivrs_block_header *ivrs_block)
         return parse_ivmd_block(ivmd_block);
 
     default:
-        amd_iov_error("IVRS Error: Invalid Block Type!\n");
+        AMD_IOMMU_DEBUG("IVRS Error: Invalid Block Type!\n");
         return -ENODEV;
     }
 
@@ -768,39 +768,37 @@ static int __init parse_ivrs_block(struct acpi_ivrs_block_header *ivrs_block)
 
 static void __init dump_acpi_table_header(struct acpi_table_header *table)
 {
-#ifdef AMD_IOV_DEBUG
     int i;
 
-    amd_iov_info("ACPI Table:\n");
-    amd_iov_info(" Signature ");
+    AMD_IOMMU_DEBUG("ACPI Table:\n");
+    AMD_IOMMU_DEBUG(" Signature ");
     for ( i = 0; i < ACPI_NAME_SIZE; i++ )
         printk("%c", table->signature[i]);
     printk("\n");
 
-    amd_iov_info(" Length 0x%x\n", table->length);
-    amd_iov_info(" Revision 0x%x\n", table->revision);
-    amd_iov_info(" CheckSum 0x%x\n", table->checksum);
+    AMD_IOMMU_DEBUG(" Length 0x%x\n", table->length);
+    AMD_IOMMU_DEBUG(" Revision 0x%x\n", table->revision);
+    AMD_IOMMU_DEBUG(" CheckSum 0x%x\n", table->checksum);
 
-    amd_iov_info(" OEM_Id ");
+    AMD_IOMMU_DEBUG(" OEM_Id ");
     for ( i = 0; i < ACPI_OEM_ID_SIZE; i++ )
         printk("%c", table->oem_id[i]);
     printk("\n");
 
-    amd_iov_info(" OEM_Table_Id ");
+    AMD_IOMMU_DEBUG(" OEM_Table_Id ");
     for ( i = 0; i < ACPI_OEM_TABLE_ID_SIZE; i++ )
         printk("%c", table->oem_table_id[i]);
     printk("\n");
 
-    amd_iov_info(" OEM_Revision 0x%x\n", table->oem_revision);
+    AMD_IOMMU_DEBUG(" OEM_Revision 0x%x\n", table->oem_revision);
 
-    amd_iov_info(" Creator_Id ");
+    AMD_IOMMU_DEBUG(" Creator_Id ");
     for ( i = 0; i < ACPI_NAME_SIZE; i++ )
         printk("%c", table->asl_compiler_id[i]);
     printk("\n");
 
-    amd_iov_info(" Creator_Revision 0x%x\n",
+    AMD_IOMMU_DEBUG(" Creator_Revision 0x%x\n",
            table->asl_compiler_revision);
-#endif
 
 }
 
@@ -813,7 +811,8 @@ static int __init parse_ivrs_table(struct acpi_table_header *_table)
 
     BUG_ON(!table);
 
-    dump_acpi_table_header(table);
+    if ( amd_iommu_debug )
+        dump_acpi_table_header(table);
 
     /* parse IVRS blocks */
     length = sizeof(struct acpi_ivrs_table_header);
@@ -822,15 +821,15 @@ static int __init parse_ivrs_table(struct acpi_table_header *_table)
         ivrs_block = (struct acpi_ivrs_block_header *)
             ((u8 *)table + length);
 
-        amd_iov_info("IVRS Block:\n");
-        amd_iov_info(" Type 0x%x\n", ivrs_block->type);
-        amd_iov_info(" Flags 0x%x\n", ivrs_block->flags);
-        amd_iov_info(" Length 0x%x\n", ivrs_block->length);
-        amd_iov_info(" Dev_Id 0x%x\n", ivrs_block->dev_id);
+        AMD_IOMMU_DEBUG("IVRS Block:\n");
+        AMD_IOMMU_DEBUG(" Type 0x%x\n", ivrs_block->type);
+        AMD_IOMMU_DEBUG(" Flags 0x%x\n", ivrs_block->flags);
+        AMD_IOMMU_DEBUG(" Length 0x%x\n", ivrs_block->length);
+        AMD_IOMMU_DEBUG(" Dev_Id 0x%x\n", ivrs_block->dev_id);
 
         if ( table->length < (length + ivrs_block->length) )
         {
-            amd_iov_error("IVRS Error: "
+            AMD_IOMMU_DEBUG("IVRS Error: "
                     "Table Length Exceeded: 0x%x -> 0x%lx\n",
                     table->length,
                     (length + ivrs_block->length));
@@ -859,7 +858,7 @@ static int __init detect_iommu_acpi(struct acpi_table_header *_table)
         checksum += raw_table[i];
     if ( checksum )
     {
-        amd_iov_error("IVRS Error: "
+        AMD_IOMMU_DEBUG("IVRS Error: "
                 "Invalid Checksum 0x%x\n", checksum);
         return -ENODEV;
     }
@@ -893,7 +892,7 @@ static int __init get_last_bdf_ivhd(void *ivhd)
     if ( ivhd_block->header.length <
          sizeof(struct acpi_ivhd_block_header) )
     {
-        amd_iov_error("IVHD Error: Invalid Block Length!\n");
+        AMD_IOMMU_DEBUG("IVHD Error: Invalid Block Length!\n");
         return -ENODEV;
     }
 
@@ -941,7 +940,7 @@ static int __init get_last_bdf_ivhd(void *ivhd)
             dev_length = sizeof(struct acpi_ivhd_device_special);
             break;
         default:
-            amd_iov_error("IVHD Error: Invalid Device Type!\n");
+            AMD_IOMMU_DEBUG("IVHD Error: Invalid Device Type!\n");
             dev_length = 0;
             break;
         }
index 9180de9aec0ffbb0405e6e7ecaa85e04551db971..155ca56e1da5c48a583d0968a65d70d34fe0d5f6 100644 (file)
@@ -62,7 +62,7 @@ static int __init get_iommu_msi_capabilities(u8 bus, u8 dev, u8 func,
     if ( !iommu->msi_cap )
         return -ENODEV;
 
-    amd_iov_info("Found MSI capability block \n");
+    AMD_IOMMU_DEBUG("Found MSI capability block \n");
     control = pci_conf_read16(bus, dev, func,
             iommu->msi_cap + PCI_MSI_FLAGS);
     iommu->maskbit = control & PCI_MSI_FLAGS_MASKBIT;
@@ -103,21 +103,21 @@ int __init amd_iommu_detect_one_acpi(void *ivhd)
 
     if ( ivhd_block->header.length < sizeof(struct acpi_ivhd_block_header) )
     {
-        amd_iov_error("Invalid IVHD Block Length!\n");
+        AMD_IOMMU_DEBUG("Invalid IVHD Block Length!\n");
         return -ENODEV;
     }
 
     if ( !ivhd_block->header.dev_id ||
         !ivhd_block->cap_offset || !ivhd_block->mmio_base)
     {
-        amd_iov_error("Invalid IVHD Block!\n");
+        AMD_IOMMU_DEBUG("Invalid IVHD Block!\n");
         return -ENODEV;
     }
 
     iommu = (struct amd_iommu *) xmalloc(struct amd_iommu);
     if ( !iommu )
     {
-        amd_iov_error("Error allocating amd_iommu\n");
+        AMD_IOMMU_DEBUG("Error allocating amd_iommu\n");
         return -ENOMEM;
     }
     memset(iommu, 0, sizeof(struct amd_iommu));
index 442c98be0b9812953683de2ddf77aa6ac5b1b52c..57ae3ce192c3e0590661f707302a8d14d087c211 100644 (file)
@@ -44,7 +44,7 @@ static int __init map_iommu_mmio_region(struct amd_iommu *iommu)
 
     if ( nr_amd_iommus > MAX_AMD_IOMMUS )
     {
-        amd_iov_error("nr_amd_iommus %d > MAX_IOMMUS\n", nr_amd_iommus);
+        AMD_IOMMU_DEBUG("nr_amd_iommus %d > MAX_IOMMUS\n", nr_amd_iommus);
         return -ENOMEM;
     }
 
@@ -437,7 +437,7 @@ static void parse_event_log_entry(u32 entry[])
     if ( (code > IOMMU_EVENT_INVALID_DEV_REQUEST) ||
         (code < IOMMU_EVENT_ILLEGAL_DEV_TABLE_ENTRY) )
     {
-        amd_iov_error("Invalid event log entry!\n");
+        AMD_IOMMU_DEBUG("Invalid event log entry!\n");
         return;
     }
 
@@ -500,7 +500,7 @@ static int set_iommu_interrupt_handler(struct amd_iommu *iommu)
         irq_desc[irq].handler = &no_irq_type;
         irq_to_iommu[irq] = NULL;
         destroy_irq(irq);
-        amd_iov_error("can't request irq\n");
+        AMD_IOMMU_DEBUG("can't request irq\n");
         return 0;
     }
 
@@ -560,7 +560,7 @@ static int __init allocate_iommu_table_struct(struct table_struct *table,
 
         if ( table->buffer == NULL )
         {
-            amd_iov_error("Error allocating %s\n", name);
+            AMD_IOMMU_DEBUG("Error allocating %s\n", name);
             return -ENOMEM;
         }
         memset(table->buffer, 0, PAGE_SIZE * (1UL << order));
@@ -684,7 +684,7 @@ static int __init init_ivrs_mapping(void)
     ivrs_mappings = xmalloc_array( struct ivrs_mappings, ivrs_bdf_entries);
     if ( ivrs_mappings == NULL )
     {
-        amd_iov_error("Error allocating IVRS Mappings table\n");
+        AMD_IOMMU_DEBUG("Error allocating IVRS Mappings table\n");
         return -ENOMEM;
     }
     memset(ivrs_mappings, 0, ivrs_bdf_entries * sizeof(struct ivrs_mappings));
@@ -757,7 +757,7 @@ static int __init amd_iommu_setup_device_table(void)
             amd_iommu_set_intremap_table(
                 dte, (u64)virt_to_maddr(intr_tb), iommu_intremap);
 
-            amd_iov_info("Add device table entry at DTE:0x%x, "
+            AMD_IOMMU_DEBUG("Add device table entry at DTE:0x%x, "
                 "intremap_table:%"PRIx64"\n", bdf,
                 (u64)virt_to_maddr(intr_tb));
         }
index d3a2873fc5d2dae44c63922c7f1dc9432679d281..00afa1cec63d75ab0830d856ab93612734f5be4e 100644 (file)
@@ -153,7 +153,7 @@ int __init amd_iommu_setup_ioapic_remapping(void)
             iommu = find_iommu_for_device(bdf);
             if ( !iommu )
             {
-                amd_iov_warning(
+                AMD_IOMMU_DEBUG(
                 "Fail to find iommu for ioapic device id = 0x%x\n", bdf);
                 continue;
             }
@@ -197,7 +197,7 @@ void amd_iommu_ioapic_update_ire(
     iommu = find_iommu_for_device(bdf);
     if ( !iommu )
     {
-        amd_iov_warning(
+        AMD_IOMMU_DEBUG(
             "Fail to find iommu for ioapic device id = 0x%x\n", bdf);
         return;
     }
@@ -285,7 +285,7 @@ void amd_iommu_msi_msg_update_ire(
 
     if ( !iommu )
     {
-        amd_iov_warning(
+        AMD_IOMMU_DEBUG(
             "Fail to find iommu for MSI device id = 0x%x\n",
             (pdev->bus << 8) | pdev->devfn);
         return;
index c88d782b357ba0f4fb1c125a91981595cc2d4457..7cb79ab436edf5edf1435668278489191994b265 100644 (file)
@@ -154,7 +154,7 @@ void flush_command_buffer(struct amd_iommu *iommu)
         }
         else
         {
-            amd_iov_warning("Warning: ComWaitInt bit did not assert!\n");
+            AMD_IOMMU_DEBUG("Warning: ComWaitInt bit did not assert!\n");
         }
     }
 }
@@ -485,7 +485,7 @@ int amd_iommu_map_page(struct domain *d, unsigned long gfn, unsigned long mfn)
     if ( iommu_l2e == 0 )
     {
         spin_unlock(&hd->mapping_lock);
-        amd_iov_error("Invalid IO pagetable entry gfn = %lx\n", gfn);
+        AMD_IOMMU_DEBUG("Invalid IO pagetable entry gfn = %lx\n", gfn);
         domain_crash(d);
         return -EFAULT;
     }
@@ -511,7 +511,7 @@ int amd_iommu_unmap_page(struct domain *d, unsigned long gfn)
     if ( iommu_l2e == 0 )
     {
         spin_unlock(&hd->mapping_lock);
-        amd_iov_error("Invalid IO pagetable entry gfn = %lx\n", gfn);
+        AMD_IOMMU_DEBUG("Invalid IO pagetable entry gfn = %lx\n", gfn);
         domain_crash(d);
         return -EFAULT;
     }
@@ -552,7 +552,7 @@ int amd_iommu_reserve_domain_unity_map(
         if ( iommu_l2e == 0 )
         {
             spin_unlock(&hd->mapping_lock);
-            amd_iov_error("Invalid IO pagetable entry phys_addr = %lx\n",
+            AMD_IOMMU_DEBUG("Invalid IO pagetable entry phys_addr = %lx\n",
                           phys_addr);
             domain_crash(domain);
             return -EFAULT;
index f99c32daf62a02dbf964149197003161d2c43daa..1ce09305c794000473976496571de403c5234cb4 100644 (file)
@@ -108,7 +108,7 @@ static void amd_iommu_setup_domain_device(
         invalidate_dev_table_entry(iommu, req_id);
         flush_command_buffer(iommu);
 
-        amd_iov_info("Setup I/O page table at DTE:0x%x, root_table:%"PRIx64","
+        AMD_IOMMU_DEBUG("Setup I/O page table at DTE:0x%x, root_table:%"PRIx64","
         "domain_id:%d, paging_mode:%d\n", req_id,
         page_to_maddr(hd->root_table), hd->domain_id, hd->paging_mode);
     }
@@ -146,7 +146,7 @@ static void amd_iommu_setup_dom0_devices(struct domain *d)
 
                 if ( !iommu )
                 {
-                    amd_iov_warning("Fail to find iommu for device"
+                    AMD_IOMMU_DEBUG("Fail to find iommu for device"
                         "%02x:%02x.%x\n", bus, dev, func);
                     continue;
                 }
@@ -163,7 +163,7 @@ int amd_iov_detect(void)
 
     if ( amd_iommu_detect_acpi() != 0 )
     {
-        amd_iov_error("Error detection\n");
+        AMD_IOMMU_DEBUG("Error detection\n");
         return -ENODEV;
     }
 
@@ -175,7 +175,7 @@ int amd_iov_detect(void)
 
     if ( amd_iommu_init() != 0 )
     {
-        amd_iov_error("Error initialization\n");
+        AMD_IOMMU_DEBUG("Error initialization\n");
         return -ENODEV;
     }
     return 0;
@@ -268,7 +268,7 @@ static void amd_iommu_disable_domain_device(
         disable_translation((u32 *)dte);
         invalidate_dev_table_entry(iommu, req_id);
         flush_command_buffer(iommu);
-        amd_iov_info("Disable DTE:0x%x,"
+        AMD_IOMMU_DEBUG("Disable DTE:0x%x,"
                 " domain_id:%d, paging_mode:%d\n",
                 req_id,  domain_hvm_iommu(domain)->domain_id,
                 domain_hvm_iommu(domain)->paging_mode);
@@ -292,7 +292,7 @@ static int reassign_device( struct domain *source, struct domain *target,
     iommu = find_iommu_for_device(bdf);
     if ( !iommu )
     {
-        amd_iov_error("Fail to find iommu."
+        AMD_IOMMU_DEBUG("Fail to find iommu."
             " %x:%x.%x cannot be assigned to domain %d\n", 
             bus, PCI_SLOT(devfn), PCI_FUNC(devfn), target->domain_id);
         return -ENODEV;
@@ -304,7 +304,7 @@ static int reassign_device( struct domain *source, struct domain *target,
     pdev->domain = target;
 
     amd_iommu_setup_domain_device(target, iommu, bdf);
-    amd_iov_info("reassign %x:%x.%x domain %d -> domain %d\n",
+    AMD_IOMMU_DEBUG("reassign %x:%x.%x domain %d -> domain %d\n",
                  bus, PCI_SLOT(devfn), PCI_FUNC(devfn),
                  source->domain_id, target->domain_id);
 
@@ -392,7 +392,7 @@ static int amd_iommu_add_device(struct pci_dev *pdev)
     iommu = find_iommu_for_device(bdf);
     if ( !iommu )
     {
-        amd_iov_error("Fail to find iommu."
+        AMD_IOMMU_DEBUG("Fail to find iommu."
             " %x:%x.%x cannot be assigned to domain %d\n", 
             pdev->bus, PCI_SLOT(pdev->devfn),
             PCI_FUNC(pdev->devfn), pdev->domain->domain_id);
@@ -414,7 +414,7 @@ static int amd_iommu_remove_device(struct pci_dev *pdev)
     iommu = find_iommu_for_device(bdf);
     if ( !iommu )
     {
-        amd_iov_error("Fail to find iommu."
+        AMD_IOMMU_DEBUG("Fail to find iommu."
             " %x:%x.%x cannot be removed from domain %d\n", 
             pdev->bus, PCI_SLOT(pdev->devfn),
             PCI_FUNC(pdev->devfn), pdev->domain->domain_id);
index 6a32dcd84f97880ecf221d6bf449057e26d42b67..0d3c079799cf767945249923b2997f606aec8ede 100644 (file)
@@ -46,6 +46,7 @@ int iommu_passthrough = 0;
 int iommu_snoop = 0;
 int iommu_qinval = 0;
 int iommu_intremap = 0;
+int amd_iommu_debug = 0;
 
 static void __init parse_iommu_param(char *s)
 {
@@ -54,6 +55,7 @@ static void __init parse_iommu_param(char *s)
     iommu_snoop = 1;
     iommu_qinval = 1;
     iommu_intremap = 1;
+    amd_iommu_debug = 0;
 
     do {
         ss = strchr(s, ',');
@@ -77,6 +79,8 @@ static void __init parse_iommu_param(char *s)
             iommu_qinval = 0;
         else if ( !strcmp(s, "no-intremap") )
             iommu_intremap = 0;
+        else if ( !strcmp(s, "amd-iommu-debug") )
+            amd_iommu_debug = 1;
 
         s = ss + 1;
     } while ( ss );
index c912142651dddf62741ac641e19e98e0d2193685..cf559dcb22a85efc82765afb7143faeb7d0f5ab8 100644 (file)
 #define DMA_32BIT_MASK  0x00000000ffffffffULL
 #define PAGE_ALIGN(addr)    (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
 
-#ifdef AMD_IOV_DEBUG
-#define amd_iov_info(fmt, args...) \
-    printk(XENLOG_INFO "AMD_IOV: " fmt, ## args)
-#define amd_iov_warning(fmt, args...) \
-    printk(XENLOG_WARNING "AMD_IOV: " fmt, ## args)
-#define amd_iov_error(fmt, args...) \
-    printk(XENLOG_ERR "AMD_IOV: %s:%d: " fmt, __FILE__ , __LINE__ , ## args)
-#else
-#define amd_iov_info(fmt, args...)
-#define amd_iov_warning(fmt, args...)
-#define amd_iov_error(fmt, args...)
-#endif
+extern int amd_iommu_debug;
+
+#define AMD_IOMMU_DEBUG(fmt, args...) \
+    do  \
+    {   \
+        if ( amd_iommu_debug )  \
+            printk(XENLOG_INFO "AMD-Vi: " fmt, ## args);    \
+    } while(0)
 
 /* amd-iommu-detect functions */
 int __init amd_iommu_get_ivrs_dev_entries(void);